﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GCELibrary.Current;
namespace ZF.BLL.UserControls
{


    public class Button : System.Web.UI.WebControls.Button
    {
        /// <summary>
        /// 绑定页面操作类型，如果设置该值，那么只有在页面为与之对应的行为相匹配才会显示该控件
        /// </summary>
        public Nullable<PageOperType> BindOper { get; set; }
        /// <summary>
        /// 根据页面的行为是判断是否显示控件
        /// </summary>
        private void SetVisibleByOperType()
        {
            if (this.Page is BLL.Page.PageBase)
            {
                var operPage = (BLL.Page.PageBase)Page;
                if (BindOper.HasValue)
                {
                    PageOperType bindOper = BindOper.Value;
                    this.Visible = (operPage.OperType & bindOper) == bindOper;
                }
            }
        }
        public Button()
            : base()
        {
            this.Init += delegate(object sender,EventArgs e)
            {
                SetVisibleByOperType();
            };
        }

 

        //protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
        //{
        //    if (!DesignMode)
        //    {
        //        base.RenderContents(writer);
        //    }
        //    else
        //    {

        //        try
        //        {
        //            base.RenderContents(writer);
        //        }
        //        catch (Exception ex)
        //        {
        //            throw ex;
        //        }
        //    }
        //}
    
    }


    
}
